﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TetrisService
{
    /// <summary>
    /// This is class is responsible for storing the current states of the game like score, 
    /// number of lines done and if the user is either playing or not.
    /// </summary>
    public class CurrentGameStatus
    {
        private int score;
        private int lines;
        private bool isPlaying = true;

        /// <summary>
        /// Initializes a new instance of the <see cref="CurrentGameStatus"/> class.
        /// </summary>
        public CurrentGameStatus()
        {
            updateScore(0);
        }

        /// <summary>
        /// Determines whether the game is over or not.
        /// </summary>
        /// <returns>
        ///   <c>true</c> if [is game over]; otherwise, <c>false</c>.
        /// </returns>
        public bool isGameOver()
        {
            return !isPlaying;
        }

        /// <summary>
        /// Gets the current level of difficulty of the game.
        /// </summary>
        /// <returns></returns>
        public int getLevel()
        {
            return (score / 1000);
        }

        /// <summary>
        /// Gets the score of the player at the current match.
        /// </summary>
        /// <returns></returns>
        public int getScore()
        {
            return score;
        }

        /// <summary>
        /// In this context, refresh time means the gravity of the game. The lower the
        /// refresh time is, the faster the pieces will go down.
        /// </summary>
        /// <returns></returns>
        public int getRefreshTime()
        {
            return 1000 - (getLevel() * 50);
        }

        /// <summary>
        /// Updates the score.
        /// </summary>
        /// <param name="score">The score.</param>
        public void updateScore(int score)
        {
            this.score = score;
        }

        /// <summary>
        /// When a line is done, this method should be called.
        /// </summary>
        /// <param name="lines">The lines.</param>
        public void addLines(int lines)
        {
            this.lines += lines;
        }

        /// <summary>
        /// Gets the number of lines done by the current player.
        /// </summary>
        /// <returns></returns>
        public int getLines()
        {
            return lines;
        }
    }
}